﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

using Kenly.DBFramework.TestModel;
using Kenly.DBFramework.TestModel.Purchasing;

using Kenly.DBFramework.Gateway;

namespace Kenly.DBFramework.TestModel
{

    /// <summary>
    /// 
    /// </summary>
    public class ModelConfigFactory : ConfigFactory
    {
        public ModelConfigFactory()
            : base(Assembly.GetExecutingAssembly())
        {
            ExceptionManager.OnConnectionException += new ConnectionHandler(ExceptionManager_OnConnectionException);
            ExceptionManager.OnCommandException += new CommandHandler(ExceptionManager_OnCommandException);
        }

        void ExceptionManager_OnConnectionException(IDbConnection sender, ConnectionEventArgs args)
        {
            //args.ThrowException = false; 
        }

        void ExceptionManager_OnCommandException(IDbCommand sender, CommandEventArgs args)
        {
            //args.ThrowException = false;         
        }

        protected override GatewayConfig CreateDefaultConfig()
        {
            return new GatewayConfig
            {
                ConnectionString = SystemConfig.ConnectionString,
                DatabaseType = SystemConfig.DatabaseType
            };
        }

        protected override void CustomizeConfigs()
        {
            this.Configs[typeof(Vendor)].DatabaseType = DatabaseType.SqlServer;
        }
    }
}
